Done = False
import blue
import sys
import os
import log
import eveLog
import autoexec_common

def SimpleNasty():
    scriptDirs = ['/../../common/script/',
     '/',
     '/../../client/script/',
     '/../../server/script/',
     '/../../backend/']
    coreToolsJessica = '/../../../../../../core_tools/MAIN/Jessica'
    coreToolsTestSuits = '/../../../../../../core_tools/MAIN/test_suites'
    scriptDirs.append(coreToolsJessica)
    scriptDirs.append(coreToolsTestSuits)
    log.general.Log('==========================================================')
    log.general.Log('Adding the directories to sys.path')
    missingpath = set()
    for scriptDir in scriptDirs:
        scriptDir = (blue.os.scriptpath + scriptDir)
        for (root, dirs, files,) in os.walk(scriptDir):
            root = root.replace('\\', '/')
            if (root[-1] == '/'):
                root = root[:-1]
            missingpath.add(os.path.normpath(root))


    for path in missingpath:
        log.general.Log(('sys.path: %s' % path))
        sys.path.append(path)

    log.general.Log('==========================================================')



def Startup(appCacheDirs, userCacheDirs, builtinSetupHook, servicesToRun, preUIStartArgProcessHook, StartupUIServiceName, startInline = []):
    global Done
    autoexec_common.LogStarting('Unity')
    SimpleNasty()
    mydocs = blue.win32.SHGetFolderPath(blue.win32.CSIDL_PERSONAL)
    paths = [blue.os.cachepath]
    for dir in appCacheDirs:
        paths.append((blue.os.cachepath + dir))

    for dir in userCacheDirs:
        paths.append((mydocs + dir))

    for path in paths:
        try:
            os.makedirs(path)
        except OSError, e:
            sys.exc_clear()

    builtinSetupHook()
    autoexec_common.LogStarted('Unity')
    import bluepy
    import numerical
    bluepy.frameClock = numerical.FrameClock()
    blue.os.frameClock = bluepy.frameClock
    title = ('[%s] %s %s %s.%s pid=%s' % (boot.region.upper(),
     boot.codename,
     boot.role,
     boot.version,
     boot.build,
     blue.os.pid))
    blue.os.SetAppTitle(title)
    Done = True



def StartClient(appCacheDirs, userCacheDirs, builtinSetupHook, servicesToRun, preUIStartArgProcessHook, StartupUIServiceName, startInline = []):
    if ('/tasklet' not in blue.pyos.GetArg()[1:]):
        import stackless
        stackless.tasklet = None
    Startup(appCacheDirs, userCacheDirs, builtinSetupHook, servicesToRun, preUIStartArgProcessHook, StartupUIServiceName, startInline)
    unityCorePath = (blue.os.rootpath + '../unity/script')
    sys.path.append(unityCorePath)
    import unity_core


appCacheDirs = []
userCacheDirs = []

def builtinSetupHook():
    return 


servicesToRun = ()

def preUIStartArgProcessHook(args):
    return 


StartupUIServiceName = None
StartClient([], [], builtinSetupHook, (), preUIStartArgProcessHook, StartupUIServiceName)

